﻿using System;
using System.Collections.Generic;
using System.Text;
using Lswweb.Model;
using Lswweb.Domain;
using Lswweb.Common;
using System.Web.UI.WebControls;

namespace Lswweb.Controls
{
    public class NewsletterEdit : SkinnedEditControl<NewsletterInfo>
    {
        private TextBox tbxEmail;

        protected override void InitSkin(System.Web.UI.Control skin)
        {
            tbxEmail = (TextBox)skin.FindControl("tbxEmail");
        }

        protected override NewsletterInfo ModelByFrom
        {
            get
            {
                NewsletterInfo entity = new NewsletterInfo();

                entity.Email = tbxEmail.GetValue<String>();

                return entity;
            }
            set
            {
                tbxEmail.SetValue(value.Email);
            }
        }

        protected override void Add(NewsletterInfo model)
        {
            Newsletter.Insert(model);
        }

        protected override void Update(NewsletterInfo model)
        {
            Newsletter.Update(model);
        }

        protected override NewsletterInfo FindById(int id)
        {
            return Newsletter.FindById(id);
        }

        protected override string DefaultSkinFilename
        {
            get { return "Newsletter/NewsletterEdit.ascx"; }
        }
    }
}
